package com.google.gwt.gfx.client.graphics.svg;

import com.google.gwt.gfx.client.graphics.Ellipse;
import com.google.gwt.gfx.client.style.AnchorStyle;

public class SVGEllipse extends Ellipse {

	private AnchorStyle anchorRef;

	public SVGEllipse() {
		super(SVG.createElement("ellipse"));

		anchorRef = new AnchorStyle(this) {

			@Override
			public int getLeft() {
				return Integer.parseInt(SVG.getElementProperty(getElement(),
						"cx"));
			}

			@Override
			public int getTop() {
				return Integer.parseInt(SVG.getElementProperty(getElement(),
						"cy"));
			}

			@Override
			public void setLeft(int left) {
				SVG.setElementProperty(getElement(), "cx", left + "");
			}

			@Override
			public void setTop(int top) {
				SVG.setElementProperty(getElement(), "cy", top + "");
			}

		};
	}

	@Override
	public AnchorStyle anchor() {
		return anchorRef;
	}

	@Override
	public int getRadiusHeight() {
		return Integer.parseInt(SVG.getElementProperty(getElement(), "ry"));
	}

	@Override
	public int getRadiusWidth() {
		return Integer.parseInt(SVG.getElementProperty(getElement(), "rx"));
	}

	@Override
	public void setRadiusHeight(int radiusHeight) {
		SVG.setElementProperty(getElement(), "ry", radiusHeight + "");
	}

	@Override
	public void setRadiusWidth(int radiusWidth) {
		SVG.setElementProperty(getElement(), "rx", radiusWidth + "");
	}

}
